package com.gavindon.plugin

import com.gavindon.plugin.task.CopyTask
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.tasks.bundling.Zip

/**
 * description:
 * Created by liNan on  2021/6/25 16:15
 */
class PluginTest : Plugin<Project> {

    override fun apply(project: Project) {
        println("MyPlugin执行了")
        project.task("mytask") {
            doLast {
                println("MyPlugin中的task执行了")
            }
        }
        //创建一个copyFile的task
        project.tasks.create("copy", CopyTask::class.java) {
//            copyFile()
            copyFiles()
        }
        project.tasks.register("zip", Zip::class.java) {
            archiveFileName.set("my-distribution.zip")
            destinationDirectory.set(project.layout.buildDirectory.dir("dist"))

            from(project.layout.buildDirectory.dir("kotlin"))
            println("${project.layout.buildDirectory.dir("kotlin")}")
        }

    }

}